/**
 * 
 */
package com.itmayiedu.response;


import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author Administrator
 * @date 2019年5月3日
 */
@Data
@Builder
public class PlatformResult implements Result {

	private static final long serialVersionUID = 1L;
	
	//状态码
	private int result;
	//提醒信息
	private String reason;
	//业务数据
	private Object data;
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	
	public static PlatformResult format(int result, String reason, Object data) {
		PlatformResult platformResult = new PlatformResult(result, reason, data);
		
		return platformResult;
	}
	
	public static PlatformResult success() {
		PlatformResult platformResult = new PlatformResult();
		platformResult.setResult(ReturnFormat.SUCCESS);
		platformResult.setReason(ReturnFormat.getDefaultReason(ReturnFormat.SUCCESS));
		return platformResult;
	}

	public static PlatformResult success(Object data) {
		PlatformResult platformResult = success();
		platformResult.setData(data);
		return platformResult;
	}

	public static PlatformResult failure(int resultCode) {
		PlatformResult platformResult = new PlatformResult();
		platformResult.setResult(resultCode);
		platformResult.setReason(ReturnFormat.getDefaultReason(resultCode));
		return platformResult;
	}

	public static PlatformResult failure(int resultCode, Object data) {
		PlatformResult platformResult = failure(resultCode);
		platformResult.setData(data);
		return platformResult;
	}
	
	
	
	@Override
	public String toString() {
		return "OutputJson [result=" + result + ", reason=" + reason + ", data=" + data + "]";
	}

	public PlatformResult(int result, String reason, Object data) {
		super();
		this.result = result;
		this.reason = reason;
		this.data = data;
	}

	public PlatformResult() {
		super();
	}
	
}
